@extends('home.layouts._master')
@push('css')
    <link rel="stylesheet" type="text/css" href="{{asset('org/home/css')}}/ziy.css">
    <link rel="stylesheet" type="text/css" href="{{asset('org/home/houl')}}/jquery.fancybox-1.3.4.css">
    <link rel="stylesheet" type="text/css" href="{{asset('org/home/houl')}}/style.css">
@endpush
@section('content')
<!--商品详情-->
<div class="breadcrumbs_container">
    <div class="left_luj">
        <ul>
          @foreach($fatherCategory as $category)
            <li>
                <a href="{{route('home.lists',$category)}}" title="{{$category['title']}}">{{$category['title']}}</a>
                <i class="icon-crumbs-right"></i>
            </li>
              @endforeach
            <li>
                <a href="javascript:;">{{$good['title']}}</a>
            </li>
        </ul>
    </div>
</div>
<div class="gome_container">
    <!--左-->
    <div class="prd_firstscreen_left">
        <!---->
        <div id="magnifier">
            <div class="small-box">
                <img src="{{$good['picture'][0]}}" style="width: 437px;height: 307px;">
                <span class="hover"></span>
            </div>
            <div class="thumbnail-box">
                <a href="javascript:;" class="btn btn-prev"></a>
                <a href="javascript:;" class="btn btn-next"></a>
                <div class="list">
                    <ul class="wrapper">
                        @foreach($good['picture'] as $k=>$picture)
                        <li class="item {{$k == 0 ? 'item-cur' : ''}}" data-src="{{$picture}}"><img src="{{$picture}}"></li>
                        @endforeach
                    </ul>
                </div>
            </div>
            <div class="big-box">
                <img src="{{$good['pics'][0]}}">
            </div>
        </div>
        <!--<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script> -->
        <script src="{{asset('org/home/js')}}/magnifier.js"></script>
        <script>
            $(function () {
                $('#magnifier').magnifier();
            });
        </script>
        <!---->
        <div class="preview-info">
            <div class="left-btns">
                <a class="" href="{{route('home.collect.make',$good)}}">
                    @if($good->isColledted())
                        已收藏
                    @else
                        收藏
                    @endif
                    <i class="sprite-compare"></i><em>商品（商品人气  {{$good['collect_num']}}）</em>
                </a>
            </div>
        </div>
    </div>
    <!--中-->
    <form action="{{route('home.order.buy',$huopin)}}" method="post">
        @csrf
        <input type="hidden" name="price" value="{{$good['price'] + $huopin['attach']}}">
        <div class="prd_firstscreen_center">
        <div class="hgroup">
            <h1>{{$good['title']}}</h1>
        </div>
        <div class="prd_price_1">
            <div class="unitprice">
                &nbsp;
                <p>
                    <label class="prd_price_left">促&nbsp;销&nbsp;价</label>
                    <span class="price" ><em>¥</em>{{$good['price'] + $huopin['attach']}}</span>
                </p>
            </div>
        </div>
        <!---->
        <div class="prd_properties">
            <div class="prd-properties-2">
                <div class="prd_properties_other">
                    <label class="prdLeft">商品属性</label>
                    <div class="prdRight">
                        @foreach($good->bale as $k => $bale)
                        <div class="prdcol">
                            <a href="{{route('home.content',['good'=>$good,'bale'=>$bale['id']])}}" class="{{$bale['id'] == $huopin['id']  ? 'select' : ''}}">
                                <span>{{$bale['natures']}}</span><i></i>
                            </a>
                        </div>
                            @endforeach
                    </div>
                </div>
            </div>
        </div>
        <div class="prd_properties_1 hou_jia">
            <label class="prd_price_left">货&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;源</label>
            <span>库存仅剩{{$huopin['stock']}}件</span>
        </div>
        <style type="text/css">
            .hou_jia{
                padding:0 10px;
            }
            .kuc_jian{
                width: 100%;
                line-height: 25px;
            }
        </style>
        <!---->
        <div class="prd_buttons">
            <div class="count-wrapper" id="btnCount">
                <input type="text" name="num" class="quantity" value="1" onchange="bian()">
                <a href="javascript:;" class="plus j-gACbtnA" onclick="add()">+</a>
                <a href="javascript:;" class="minus j-gACbtn" onclick="del()">-</a>
            </div>
            @if($huopin['stock'])
                <button class="btn-product btn-addcart" style="height: 42px;cursor: pointer;">立即购买</button>
            <a href="javascript:;" onclick="addCart()" class="btn-product">加入购物车</a>
            @else
            <a href="javascript:;" class="btn-product">暂时缺货</a>
             @endif
        </div>

        <script>
            var num = $('.quantity').val();
            function add() {
                // alert(111);
              if (num>{{$huopin['stock']}}){
                  $('.quantity').val({{$huopin['stock']}});
              } else {
                  // alert(111);
                  num++;
                  $('.quantity').val(num);
              }
            }
            function del() {
                if (num>1){
                    num--;
                    $('.quantity').val(num);
                } else {
                    $('.quantity').val(1);
                }
            }
            function bian() {
                var num = $('.quantity').val();
               if (num<1)
               {
                   $('.quantity').val(1);
               }
               if(num>{{$huopin['stock']}})
                {
                    $('.quantity').val({{$huopin['stock']}});
                }
            }
        </script>

        <!---->
        <div class="prd-tips wenxintishi_wrap clearfix">
            <p>温馨提示</p>
            <ol class="wenxinti">
                <li>
                    正品保障；
                    支持7天无理由退货
                </li>
            </ol>
        </div>
        <!---->
    </div>
    </form>
</div>
<script>
    function addCart() {
        var num = $('.quantity').val();
        location.href = '/addCart/{{$good['id']}}/{{$huopin['id']}}/' + num;
    }
</script>

<!--商品信息结束-->
<!--详情-->
<div class="shangp_xiangq_neir_beij">
    <!--left-->
    <div class="shangp_xiangq_left">
        <!---->
        <div class="shangp_xiangq_left_biank">
            <div class="stores-infos">
                <div class="ly-stores">
                    <h2 class="fix-storesname shops-name" id="store_live800_wrap">
                        <a class="name" title="推荐商品" href="#" target="_blank">推荐商品</a>
                    </h2>
                    <ul class="bend_shangp_lieb">
                        @foreach($commendGoods as $commendGood)
                        <li>
                            <a href="{{route('home.content',$commendGood)}}">
                                <img src="{{$commendGood['picture'][0]}}">
                                <h3>￥{{$commendGood['price']}}</h3>
                                <p>{{$commendGood['title']}}</p>
                            </a>
                        </li>
                            @endforeach
                    </ul>
                </div>
            </div>
        </div>
        <!---->
        <div class="shangp_xiangq_left_biank">
            <div class="stores-infos">
                <div class="ly-stores">
                    <h2 class="fix-storesname shops-name" id="store_live800_wrap">
                        <a class="name" title="热门商品" href="#" target="_blank">热门商品</a>
                    </h2>
                    <ul class="bend_shangp_lieb">
                        @foreach($hotGoods as $hotGood)
                        <li>
                            <a href="{{route('home.content',$hotGood)}}">
                                <img src="{{$hotGood['picture'][0]}}">
                                <h3>￥{{$hotGood['price']}}</h3>
                                <p>{{$hotGood['title']}}</p>
                            </a>
                        </li>
                            @endforeach
                    </ul>
                </div>
            </div>
        </div>
        <!---->
    </div>
    <!--right-->
    <div class="shangp_xiangq_right">
        <!---->
        <div class="slideTxtBox_1">
            <div class="hd">
                <ul><li>商品介绍</li></ul>
                <div class="extra_jiar_gouw_c">
                    <a href="javascript:;" onclick="addCart()">加入购物车</a>
                </div>
            </div>
            <div class="bd">
                <ul>
                    <div class="p_parameter">
                        {!! $good['content'] !!}
                    </div>
                </ul>
            </div>
        </div>
        <script type="text/javascript">jQuery(".slideTxtBox_1").slide({trigger:"click"});</script>
        <!---->
    </div>
</div>
@endsection

